package com.monkey.apple.app.videoApp;

import android.graphics.Bitmap;
import android.media.ThumbnailUtils;
import android.provider.MediaStore;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Description: 视频Bean
 * Author: Archur
 * Date: 2017-10-15
 * Time: 8:55
 */


public class VideoItem {

    String name;
    String path;
    Bitmap thumb;
    String createdTime;

    public VideoItem(String name, String path, String createdTime) {
        this.name = name;
        this.path = path;

        // 时间戳转换成可读时间
        SimpleDateFormat sf = new SimpleDateFormat("yy年MM月dd日HH时mm分");
        Date d = new Date(Long.valueOf(createdTime)*1000);
        this.createdTime = sf.format(d);

        // 利用视频文件地址获取视频缩略图的工具
        // MediaStore.Images.Thumbnails.MICRO_KIND 超小图的缩略图
        // MediaStore.Images.Thumbnails.MINI_KIND 小的缩略图
        // MediaStore.Images.Thumbnails.FULL_SCREEN_KIND 大尺寸的缩略图

        this.thumb = ThumbnailUtils.createVideoThumbnail(name, MediaStore.Images.Thumbnails.MINI_KIND);
    }

    @Override
    public String toString() {
        return "VideoItem{" +
                "name='" + name + '\'' +
                ", path='" + path + '\'' +
                ", thumb=" + thumb +
                ", createdTime='" + createdTime + '\'' +
                '}';
    }
}
